package cn.mandifal.user.controller;

import cn.mandifal.order.service.OrderService;
import com.alibaba.dubbo.config.annotation.Reference;
import entity.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 退款控制层
 * @author shun
 */
@RestController
@RequestMapping("/refundController")
public class RefundController {
    @Reference
    private OrderService orderService;
    /**
     * 申请退款
     * @param orderItemId 订单详情 id
     * @return
     */
    @RequestMapping("/submitRefundRequest")
    public Result submitRefundRequest(String orderItemId){
        try {
            //修改订单状态，6 为申请退款
            orderService.updateStatus(orderItemId,"6");
            return Result.success("申请退款成功，请等待商家确认");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.failed("申请失败");
        }
    }
}
